package com.dzy.result;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

@Data
@AllArgsConstructor
@NoArgsConstructor
@Accessors(chain = true)
public class JsonResult<T> {

    private String code;
    private String message;
    private T data;

    public JsonResult(String code, String message) {
        this.code = code;
        this.message = message;
    }

    public static JsonResult success(){
        return new JsonResult(ResultConstants.SUCCESS.getCode(), ResultConstants.SUCCESS.getMessage());
    }

    public static JsonResult error(){
        return new JsonResult(ResultConstants.ERROR.getCode(), ResultConstants.ERROR.getMessage());
    }

}
